package com.shop.goods.service.impl;

import java.util.List;

import com.shop.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.shop.goods.mapper.ShopGoodsMapper;
import com.shop.goods.domain.ShopGoods;
import com.shop.goods.service.IShopGoodsService;

/**
 * 商品信息Service业务层处理
 *
 * @author ruoyi
 * @date 2022-04-04
 */
@Service
public class ShopGoodsServiceImpl implements IShopGoodsService {
    @Autowired
    private ShopGoodsMapper shopGoodsMapper;

    /**
     * 查询商品信息
     *
     * @param id 商品信息主键
     * @return 商品信息
     */
    @Override
    public ShopGoods selectShopGoodsById(Long id) {
        return shopGoodsMapper.selectShopGoodsById(id);
    }

    /**
     * 查询商品信息列表
     *
     * @param shopGoods 商品信息
     * @return 商品信息
     */
    @Override
    public List<ShopGoods> selectShopGoodsList(ShopGoods shopGoods) {
        return shopGoodsMapper.selectShopGoodsList(shopGoods);
    }

    /**
     * 新增商品信息
     *
     * @param shopGoods 商品信息
     * @return 结果
     */
    @Override
    public int insertShopGoods(ShopGoods shopGoods) {
        shopGoods.setCreateTime(DateUtils.getNowDate());
        return shopGoodsMapper.insertShopGoods(shopGoods);
    }

    /**
     * 修改商品信息
     *
     * @param shopGoods 商品信息
     * @return 结果
     */
    @Override
    public int updateShopGoods(ShopGoods shopGoods) {
        shopGoods.setUpdateTime(DateUtils.getNowDate());
        return shopGoodsMapper.updateShopGoods(shopGoods);
    }

    /**
     * 批量删除商品信息
     *
     * @param ids 需要删除的商品信息主键
     * @return 结果
     */
    @Override
    public int deleteShopGoodsByIds(Long[] ids) {
        return shopGoodsMapper.deleteShopGoodsByIds(ids);
    }

    /**
     * 删除商品信息信息
     *
     * @param id 商品信息主键
     * @return 结果
     */
    @Override
    public int deleteShopGoodsById(Long id) {
        return shopGoodsMapper.deleteShopGoodsById(id);
    }

    /**
     * 获取热销商品
     * 无参====id=1=>热销
     *
     * @return 结果
     */
    @Override
    public List<ShopGoods> selectHot(ShopGoods shopGoods) {
        return shopGoodsMapper.selectHot(shopGoods);
    }
    public List<ShopGoods> selectIntegral(ShopGoods shopGoods) {
        return shopGoodsMapper.selectIntegral(shopGoods);
    }

    /**
     * 获取分类商品信息
     *
     * @return 结果
     */
    public List<ShopGoods> selectBySort(ShopGoods shopGoods) {
        return shopGoodsMapper.selectBySort(shopGoods);
    }
}
